package net.huashitong.user.service;

import com.sirdc.modules.core.dao.BaseDao;
import com.sirdc.modules.core.filter.Paging;
import com.sirdc.modules.sys.base.StringPKService;
import com.sirdc.modules.sys.service.SysTableService;
import net.huashitong.user.dao.TemporaryMessageDao;
import net.huashitong.user.entity.Message;
import net.huashitong.user.entity.TemporaryMessage;
import net.huashitong.user.filter.MessageFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TemporaryMessageService extends StringPKService<TemporaryMessage> {
   @Autowired
   private TemporaryMessageDao dao;
    @Autowired
    private SysTableService tableService;

   @Override
    protected BaseDao<TemporaryMessage, String> getDao() {
        return dao;
   }

    protected void beforeSave(TemporaryMessage obj) {
        obj.setSysId(tableService.updateMaxSysId("t_bnp_message_temporary", null));
    }
    public List<TemporaryMessage> getTemporaryMessageInfo(MessageFilter filter){
        if (filter.getPage() == null) {
            filter.setPage(0);
        }
        Paging p = new Paging();
        p.setCurrentPage(filter.getPage() + 1);
        filter.setPaging(p);
       return dao.getTemporaryMessageInfo(filter);
    }
    public List<TemporaryMessage> getMessageModels(String projectName,String nodeId,String phone){
       return dao.getMessageModels(projectName,nodeId,phone);
    }
    public List<TemporaryMessage> getTemporaryMessageInfos(){
        return dao.getTemporaryMessageInfos();
    }
}
